<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        td{
            font-size: 10px;
            width: 300px;
            height: 20px;
        }
    </style>
    <script>
        var n = "a",i = 0;
        var si = null;
        function f1() {
            si = setInterval('sj()',2000);
        }
        function sj() {
            if (i!=13){
                var a = Math.floor(Math.random()*(1000-1))+1+"";
                var a1 = a.length<2 ?"000"+a:a.length<3?"00"+a:a.length<4?"0"+a:a;
                document.getElementById("sz").innerHTML = a1;
                document.getElementById(n+(++i)).innerHTML = a1;
            }else {
                document.getElementById("ks").onclick = ffff;
                document.getElementById("tz").onclick = ffff;
            }
        }
    </script>
</head>
<body>
    <div style="width: 100px;margin: 0 auto" id="sjs">
        <font style="padding-left: 25px" id="sz"></font><br><br><br><br><br>
        <button id="ks" style="margin-right: 2px" onclick="f1()">开始</button><button id="tz" onclick="clearInterval(si)">停止</button>
    </div>
    <table border="1" cellspacing="1" cellpadding="1" style="background-color: aquamarine">
        <tr>
            <td id="a1"></td>
            <td id="a2"></td>
            <td id="a3"></td>
            <td id="a4"></td>
        </tr>
        <tr>
            <td id="a5"></td>
            <td id="a6"></td>
            <td id="a7"></td>
            <td id="a8"></td>
        </tr>
        <tr>
            <td id="a9"></td>
            <td id="a10"></td>
            <td id="a11"></td>
            <td id="a12"></td>
        </tr>
    </table>
</body>
</html>